<HTML><HEAD><TITLE>module(+Module)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Modules</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>module(+Module)</H1>
Begin of the definition of module Module.
<DL>
<DT><EM>Module</EM></DT>
<DD>Atom.
</DD>
</DL>
<H2>Description</H2>
   This is a directive that can occur only in a compiled file.  If Module
   is an existing module, it is first erased.  Then a new module is created
   and all subsequent definitions, declarations and directives are taken
   in the context of that new module.
<P>
   The new module implicitly imports the module <CODE>eclipse_language</CODE>,
   which means that all ECLiPSe built-ins are visible there.
<P>
   <CODE>module(m)</CODE> is equivalent to <CODE>module(m,[],eclipse_language)</CODE>.
<P>
   Note that module/1 is not a predicate, it can only occur as a
   directive in a compiled file.  However, the console based ECLiPSe
   toplevel also interprets module/1 commands, but in the following
   way:  when the module already exists, the toplevel-module (i.e. 
   the context in which toplevel queries are interpreted) is changed
   to this module.  When the module does not exist, it gets created
   and a warning is issued.
<P>
   The system does not allow the atom [] to be used as a module name!

<H3>Modes and Determinism</H3><UL>
<LI>module(+) is det
</UL>
<H3>Exceptions</H3>
<DL>
<DT><EM>(4) instantiation fault </EM>
<DD>Module is not instantiated.
<DT><EM>(5) type error </EM>
<DD>Module is not an atom, or Module is the atom [].
<DT><EM>(68) calling an undefined procedure </EM>
<DD>When called from Prolog.
<DT><EM>(82) trying to access a locked module </EM>
<DD>Module is locked.
</DL>
<H2>Examples</H2>
<PRE>
% A very small module:
     :- module(m).
     :- export hello/0.
     hello :- writeln("Welcome to module m!").
</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/modules/module-1.html">module / 1</A>, <A HREF="../../kernel/modules/module-3.html">module / 3</A>, <A HREF="../../kernel/modules/create_module-1.html">create_module / 1</A>, <A HREF="../../kernel/modules/create_module-3.html">create_module / 3</A>, <A HREF="../../kernel/modules/erase_module-1.html">erase_module / 1</A>, <A HREF="../../kernel/modules/current_module-1.html">current_module / 1</A>, <A HREF="../../kernel/modules/export-1.html">export / 1</A>
</BODY></HTML>
